package com.css.cloudlearn.productornacos.route;

import com.css.dynamic.conanst.CacheConstants;
import com.css.dynamic.dynamicRoute.RouteCacheHolder;
import com.css.dynamic.dynamicRoute.RouteDefinitionVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.gateway.event.RefreshRoutesEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.nio.channels.Channel;
import java.util.List;

/**
 * @author 郭辉
 * @className TODO
 * @description TODO
 * @date 2022/8/15 15:46
 * @company 海康威视
 * @since 1.0.0
 */
@RestController
@RequestMapping("/api/productor-nacos")
public class ApiController {

    @Value("${token}")
    private String token;

    @RequestMapping("/hello")
    public String hello() {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        System.out.println(request.getHeader("gateway"));
        System.out.println(token);
        return "Productor - nacos";
    }

    @RequestMapping("/ping")
    public String ping() {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        System.out.println(request.getHeader("gateway"));
        System.out.println(token);
        return "Productor - pong";
    }


}
